home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_1199 / 1616 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  6.7 KB

  1. From: Kay Roemer <roemer@informatik.uni-frankfurt.de>
  2. Posted-Date: Tue, 21 Jun 94 15:52:04 MESZ
  3. Received-Date: Tue, 21 Jun 94 15:52:04 +0200
  4. Message-Id: <9406211352.AA10584@hera.rbi.informatik.uni-frankfurt.de>
  5. Subject: ser. overrun/daedlock fix
  6. To: mint@atari.archive.umich.edu
  7. Date: Tue, 21 Jun 94 15:52:04 MESZ
  8. Mailer: Elm [revision: 70.85]
  9.  
  10. The following set of patches rel to h1 Megapatch (sorry, hadn't yet
  11. the time to get h2 or h3) is a better solution (at least I think) to
  12. the 'endless serial overrun' story, because it avoids the spl7()
  13. in Fselect() completely plus deadlock fix.
  14.  
  15. The solution is as follows:
  16.  
  17. curproc->wait_cond = condition;
  18. while (curproc->wait_cond == condition) {
  19.     sleep (SELECT_Q | 0x100, condition);
  20. }
  21.  
  22. works the same as
  23.  
  24. curproc->wait_cond = condition;
  25. sr = spl7();
  26. while (curproc->wait_cond == condition) {
  27.     sleep (SELECT_Q, condition);
  28. }
  29. spl(sr);
  30.  
  31. The 0x100 tells sleep() to return without sleeping when curproc->wait_cond
  32. changes. This way we don't need spl7 (avoiding endless serial overruns).
  33. Also fixes a deadlock with checkkeys/checkbttys. They are called from
  34. sleep and may wakeselect() curproc. But sleep used to reset curproc->wait_cond
  35. to (long)wakeselect causing curproc to sleep forever.
  36.  
  37. Kay.
  38.  
  39. *** ../mint-110h1.orig/proc.c    Mon Jun 20 23:20:20 1994
  40. --- proc.c    Mon Jun 20 23:24:10 1994
  41. ***************
  42. *** 9,15 ****
  43.   #include "mint.h"
  44.   #include "xbra.h"
  45.   
  46. ! static void do_wakeup_things P_((short sr));
  47.   
  48.   extern short proc_clock;
  49.   
  50. --- 9,15 ----
  51.   #include "mint.h"
  52.   #include "xbra.h"
  53.   
  54. ! static void do_wakeup_things P_((void));
  55.   
  56.   extern short proc_clock;
  57.   
  58. ***************
  59. *** 419,426 ****
  60.    */
  61.   
  62.   static void
  63. ! do_wakeup_things(sr)
  64. ! short sr;
  65.   {
  66.   /*
  67.    * check for stack underflow, just in case
  68. --- 419,425 ----
  69.    */
  70.   
  71.   static void
  72. ! do_wakeup_things()
  73.   {
  74.   /*
  75.    * check for stack underflow, just in case
  76. ***************
  77. *** 430,438 ****
  78.   
  79.       p = curproc;
  80.   
  81. -     if ((sr & 0x700) < 0x500) {
  82. - /* skip all this if int level is too high */
  83.       if ( p->pid != 0 &&
  84.            ((long)&foo) < (long)p->stack + ISTKSIZE + 512 ) {
  85.           ALERT("stack underflow");
  86. --- 429,434 ----
  87. ***************
  88. *** 455,461 ****
  89.       checkalarms();
  90.       if (p->sigpending)
  91.           check_sigs();        /* check for signals */
  92. -     }
  93.   
  94.       if (p->slices >= 0) {
  95.       proc_clock = TIME_SLICE;    /* get a fresh time slice */
  96. --- 451,456 ----
  97. ***************
  98. *** 472,483 ****
  99.    */
  100.   
  101.   int ARGS_ON_STACK 
  102. ! sleep(que, cond)
  103. !     int que;
  104.       long cond;
  105.   {
  106.       PROC *p;
  107. !     short sr;
  108.       ulong onsigs = curproc->nsigs;
  109.       extern short kintr;    /* in bios.c */
  110.   #ifndef MULTITOS
  111. --- 467,478 ----
  112.    */
  113.   
  114.   int ARGS_ON_STACK 
  115. ! sleep(_que, cond)
  116. !     int _que;
  117.       long cond;
  118.   {
  119.       PROC *p;
  120. !     short sr, que = _que & 0xff;
  121.       ulong onsigs = curproc->nsigs;
  122.       extern short kintr;    /* in bios.c */
  123.   #ifndef MULTITOS
  124. ***************
  125. *** 490,509 ****
  126.    * if there have been keyboard interrupts since our last sleep, check for
  127.    * special keys like CTRL-ALT-Fx
  128.    */
  129. !     sr = spl7();
  130. !     if (kintr && (sr & 0x700) < 0x500) {
  131. ! /* can't call checkkeys if sleep was called with interrupts off  -nox */
  132. !         spl(sr);
  133.           (void)checkkeys();
  134. -         sr = spl7();
  135.           kintr = 0;
  136.       }
  137.   
  138. !     if (que == READY_Q && !sys_q[READY_Q]) {
  139.   /* we're just going to wake up again right away! */
  140.           spl(sr);
  141. !         do_wakeup_things(sr);
  142.           return (onsigs != curproc->nsigs);
  143.       }
  144.   
  145. --- 485,507 ----
  146.    * if there have been keyboard interrupts since our last sleep, check for
  147.    * special keys like CTRL-ALT-Fx
  148.    */
  149. !     checkbttys();
  150. !     if (kintr) {
  151.           (void)checkkeys();
  152.           kintr = 0;
  153.       }
  154.   
  155. !     sr = spl7();
  156. ! /*
  157. !  * kay: If _que & 0x100 != 0 then take curproc->wait_cond != cond as an
  158. !  * indicatation that the wakeup has already happend before we actually
  159. !  * go to sleep and return immediatly.
  160. !  */
  161. !     if ((_que & 0x100 && curproc->wait_cond != cond) ||
  162. !         (que == READY_Q && !sys_q[READY_Q])) {
  163.   /* we're just going to wake up again right away! */
  164.           spl(sr);
  165. !         do_wakeup_things();
  166.           return (onsigs != curproc->nsigs);
  167.       }
  168.   
  169. ***************
  170. *** 559,566 ****
  171.   
  172.       rm_q(READY_Q, p);
  173.   
  174. -     spl(sr);
  175.       if (save_context(&(curproc->ctxt[CURRENT]))) {
  176.   /*
  177.    * restore per-process variables here
  178. --- 557,562 ----
  179. ***************
  180. *** 571,577 ****
  181.   #endif
  182.               *((void **)0x44eL) = curproc->logbase;
  183.   #endif
  184. !         do_wakeup_things(sr);
  185.           return (onsigs != curproc->nsigs);
  186.       }
  187.   /*
  188. --- 567,573 ----
  189.   #endif
  190.               *((void **)0x44eL) = curproc->logbase;
  191.   #endif
  192. !         do_wakeup_things();
  193.           return (onsigs != curproc->nsigs);
  194.       }
  195.   /*
  196. ***************
  197. *** 583,588 ****
  198. --- 579,590 ----
  199.   #endif
  200.           curproc->logbase = *((void **)0x44eL);
  201.   #endif
  202. + /*
  203. +  * kay: We were at spl7 when doing the save_context(). Correct this.
  204. +  */
  205. +     curproc->ctxt[CURRENT].sr &= ~0x0700;
  206. +     curproc->ctxt[CURRENT].sr |= sr & 0x0700;
  207.       curproc->ctxt[CURRENT].regs[0] = 1;
  208.       curproc = p;
  209.       proc_clock = TIME_SLICE;    /* fresh time */
  210. *** ../mint-110h1.orig/dosfile.c    Mon Jun 20 23:19:54 1994
  211. --- dosfile.c    Mon Jun 20 11:54:44 1994
  212. ***************
  213. *** 977,983 ****
  214.       FILEPTR *f;
  215.       PROC *p;
  216.       TIMEOUT *t;
  217. -     short sr;
  218.   
  219.       if (xfdp)
  220.           *xfdp = 0;
  221. --- 977,982 ----
  222. ***************
  223. *** 1045,1051 ****
  224.       }
  225.   
  226.       if (count == 0) {
  227. -         ulong onsigs;
  228.           /* OK, now let's set a timeout */
  229.   
  230.           if (timeout) {
  231. --- 1044,1049 ----
  232. ***************
  233. *** 1054,1079 ****
  234.               t = 0;
  235.           }
  236.   
  237. -         TRACE(("sleeping in Fselect"));
  238. -         sr = spl7();
  239.       /* curproc->wait_cond changes when data arrives or the timeout happens */
  240. -         onsigs = curproc->nsigs;
  241.           while (curproc->wait_cond == (long)wakeselect) {
  242. - #if 0
  243. - /* better not call BIOS with interrupts off, especially not Bconin... :) */
  244.               TRACE(("sleeping in Fselect"));
  245. ! #endif
  246. !             sleep(SELECT_Q, (long)wakeselect);
  247. !             if (curproc->sigpending) {
  248. !                 spl(sr);    /* check for signals */
  249. !                 check_sigs();
  250. !                 sr = spl7();
  251. !             }
  252. !             if (onsigs != curproc->nsigs)
  253.                   break;
  254.           }
  255. -         spl(sr);
  256.   
  257.       /* we can cancel the time out now (if it hasn't already happened) */
  258.           if (t) canceltimeout(t);
  259. --- 1052,1072 ----
  260.               t = 0;
  261.           }
  262.   
  263.       /* curproc->wait_cond changes when data arrives or the timeout happens */
  264.           while (curproc->wait_cond == (long)wakeselect) {
  265.               TRACE(("sleeping in Fselect"));
  266. !             /*
  267. !              * The 0x100 tells sleep() to return without sleeping
  268. !              * when curproc->wait_cond changes. This way we don't
  269. !              * need spl7 (avoiding endless serial overruns).
  270. !              * Also fixes a deadlock with checkkeys/checkbttys.
  271. !              * They are called from sleep and may wakeselect()
  272. !              * curproc. But sleep used to reset curproc->wait_cond
  273. !              * to wakeselect causing curproc to sleep forever.
  274. !              */
  275. !             if (sleep(SELECT_Q|0x100, (long)wakeselect))
  276.                   break;
  277.           }
  278.   
  279.       /* we can cancel the time out now (if it hasn't already happened) */
  280.           if (t) canceltimeout(t);
  281.